<?php
include "controller/view.php";
include('/controller/maincontroller.php');
class dispatcher {
        function load() {
                 if (isset($_GET['controller'])) {
                        switch ($_GET['controller']) {
                                case "registracia": // registracia  organizátora/rozhodcu        
												if(isset($_SESSION['user']->Admin)){
													include('/controller/registration.php');
													$registration = New registration();
													if (isset($_GET['action'])){ 
														return $registration->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												} else {
													return view::load('neopravnenipristup', array());
												}
												
                                               
                                    											
								case "prihlasenie": // prihlasenie
                                                include('/controller/login.php');
                                                $login = New login();
												if (isset($_GET['action'])){ 
													return $login->handle($_GET['action']);
												} else { return view::load('error404', array()); }
                                                break;
                                
								
								case "mojucet":// ucet usera
												include('/controller/mojucet.php');
                                                $mojucet = New mojucet();
												if (isset($_GET['action'])){ 
													return $mojucet->handle($_GET['action']);
												} else { return view::load('error404', array()); }
                                                break;
                                case "kontakt": // konakt
												return view::load('kontakt', array()); 
												break;
								case "help": // konakt
												return view::load('help', array()); 
												break;
								case "sutaz": //sutaz
												if(isset($_SESSION['user']->Admin)){
													include('/controller/sutaz.php');
													$sutaz = New sutaz('sutaz');											
													if (isset($_GET['action'])){ 
														return $sutaz->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												}else {
													return view::load('neopravnenipristup',array());
												}
								case "sutaznakategoria": //kategoria
												if(isset($_SESSION['user']->Admin)){
													include('/controller/sutaznakategoria.php');
													$sutaznakategoria = New sutaznakategoria('sutazna_kategoria');											
													if (isset($_GET['action'])){ 	
														return $sutaznakategoria->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												}else {
													return view::load('neopravnenipristup',array());
												}
								case "sutaziaci": //sutaziaci
												if(isset($_SESSION['user']->Admin)){
													include('/controller/sutaziaci.php');
													$sutaziaci = New sutaziaci('sutaziaci');											
													if (isset($_GET['action'])){ 
														return $sutaziaci->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												}else {
													return view::load('neopravnenipristup',array());
												}
								case "kategoriahodnotenia": //typ kategoria hodnotenia     
												if(isset($_SESSION['user']->Admin)){
													include('/controller/kategoriahodnotenia.php');
													$kategoriahodnotenia = New kategoriahodnotenia('typ_kategoria_hodnotenia');											
													if (isset($_GET['action'])){ 
														return $kategoriahodnotenia->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												} else {
													return view::load('neopravnenipristup',array());
												}
								case "sutaznekolo": //sutazne kolo     
												if(isset($_SESSION['user']->Admin)){
													include('/controller/sutaznekolo.php');
													$sutaznekolo = New sutaznekolo('sutazne_kolo');											
													if (isset($_GET['action'])){ 
														return $sutaznekolo->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												} else {
													return view::load('neopravnenipristup',array());
												}
								case "scitacisystem": //sutazne kolo     
												if(isset($_SESSION['user']->Admin)){
													include('/controller/scitacisystem.php');
													$scitacisytem = New scitacisystem();											
													if (isset($_GET['action'])){ 
														return $scitacisytem->handle($_GET['action']);
													} else { return view::load('error404', array()); }
													break;
												} else {
													return view::load('neopravnenipristup',array());
												}
                                default: 
									return  view::load('error404', array());                   
                        }       
                } else {	
					return  view::load('home', array()); 
                }
                
        }
}
?>
